<template>
	<view>
		<view class="title">添加本人银行卡</view>
		<view class="summary">
			<text>请添加本人的储蓄卡作为结算卡，最好是一类卡，该卡作为后续的结算账户，</text>
			<text class="yellow">户名必须和实名认证的姓名一致</text>
		</view>
		<view class="com-form">
			<view class="com-form-item">
				<view class="label">持卡人：</view>
				<view class="inputbox">
					<input :value="username" disabled="true" />
				</view>
			</view>
			<view class="com-form-item">
				<view class="label">银行卡号：</view>
				<view class="inputbox">
					<input type="number" v-model="card" />
				</view>
			</view>
			<view class="com-form-item">
				<view class="label">预留手机号：</view>
				<view class="inputbox">
					<input type="number" v-model="mobile" maxlength="11" />
				</view>
			</view>
		</view>
		<view class="com-btn" @click="add">
			<button>完成</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isuser: true,
				username: '',
				card: '',
				mobile: '',
				id:'',
				isVerify:false
			}
		},
		
		onLoad(option){
			if(option.id){
				this.id = option.id;
				
			}
			console.info("======id====="+this.id);
		},

		onShow() {
			this.init();
		},
		methods: {

			init(){
				
				let param ={};
				let that = this;
				this.$api.verifyDetail(param).then(res => {
				
					console.info(res);
					if (res.code == 1) {
						if(res.data == null || res.data.status != 1){
							
							uni.showModal({
								title: '提示',
								content: '你未实名认证',
								showCancel: false,
								confirmText: '立即认证',
								success(res) {
									if (res.confirm) {
										uni.navigateTo({
											url:'./realName'
										})
									}
								}
							})
						}else{
							that.username = res.data.username;
						}
						
					}else{
						
					}
				})
				
			},
			add() {
				if (this.card == '') {
					this.$util.$showToast('请填入卡号', '', 'none');
					return;
				}
				if (this.mobile == '') {
					this.$util.$showToast('请填入手机号', '', 'none');
					return;
				}
				
				if(this.id == ''){
					let param = {
						bankNum:this.card,
						bankPhone:this.mobile
					}
					let that = this;
					this.$api.bankAnd(param).then(res => {
					
						if (res.code == 1) {
							uni.navigateBack({
								delta: 1
							})
						} else {
							this.$util.$showToast(res.msg, '', 'none');
					
						}
					})
				}else{
					let param = {
						bankNum:this.card,
						bankPhone:this.mobile,
						id:this.id
					}
					let that = this;
					this.$api.bankUpdate(param).then(res => {
					
						if (res.code == 1) {
							uni.navigateBack({
								delta: 1
							})
						} else {
							this.$util.$showToast(res.msg, '', 'none');
					
						}
					})
				}
				

			},


			getPage(url) {
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style lang="scss">
	.title {
		font-size: 36rpx;
		color: #333333;
		text-align: center;
		margin: 103rpx 0 38rpx 0;
		font-weight: bold;
	}

	.summary {
		margin: 0 65rpx 30rpx;
		font-size: 28rpx;
		color: #666666;
		text-align: center;

		.yellow {
			color: #E69825;
		}
	}

	.com-form {
		background: #FFFFFF;

		.com-form-item {
			padding: 20rpx 30rpx;
			margin: 0 30rpx;
			display: flex;
			border-bottom: 1rpx solid #EFEFEF;
			height: 70rpx;

			.label {
				font-size: 30rpx;
				color: #666666;
				margin-top: 15rpx;
			}

			.inputbox {
				flex: auto;
				height: 70rpx;
				line-height: 70rpx;
				text-align: left;
				padding: 0 40rpx 0 20rpx;

				input {
					height: 70rpx;
					line-height: 70rpx;
					width: 100%;
					padding: 0 0 0 20rpx;
					color: #333333;
					font-size: 30rpx;
				}
			}
		}
	}
</style>
